<?php

require_once dirname(__FILE__) . '/Dice.php';
require_once dirname(__FILE__) . '/Game.php';
require_once dirname(__FILE__) . '/Board/SpaceMaker.php';
require_once dirname(__FILE__) . '/Board/Monopoly.php';
require_once dirname(__FILE__) . '/Player/Piece.php';
require_once dirname(__FILE__) . '/Player.php';

$dice = new Dice('SixSided', 2);

$space_maker = new Board_SpaceMaker();
$board = new Board_Monopoly($space_maker);

$players = array();

$piece = new Player_Piece('horse');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('car');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('snake');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('spoon');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('shoe');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('iron');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('subir');
$players[] = new Player($piece, $board->getSpace('Go'));

$piece = new Player_Piece('can');
$players[] = new Player($piece, $board->getSpace('Go'));

$game = new Game($dice, $board, $players);

// play 20 rounds
for ($i = 0; $i < 20; $i++) {
    $game->playRound();
}

echo "Game Rounds:" . $game->getRoundsPlayed() . "\n";

$initial_order = $game->getPlayers();

foreach ($game->getPlayers() as $player) {
    echo $player->getPiece()->getName() . " Rounds:" . $player->getTurnsPlayed() . "\t\t\tat " . $player->getSpace()->getName() . "\n";
}

echo "Initial order:\t" . implode(', ', $initial_order) . "\n";
echo "Final order:\t" . implode(', ', $game->getPlayers()) . "\n";
